package service;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.fragment.app.Fragment;

import com.example.save.R;

public class start extends Fragment {

    private Button PlayMusicButton;
    private Button StopMusicButton;

    public start(){
        super(R.layout.fragment7);
    }


    @Override
    public void onViewCreated(View view, Bundle savedStanceState){
        super.onViewCreated(view,savedStanceState);

        //播放
        PlayMusicButton=getView().findViewById(R.id.button1);
        PlayMusicButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(getActivity(),MusicService.class);
                getActivity().startService(intent);
            }
        });


        //停止
        StopMusicButton=getView().findViewById(R.id.button7);
        StopMusicButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(getActivity(),MusicService.class);
                getActivity().stopService(intent);
            }
        });
    }
}
